import java.util.HashSet;

public class Text {
    public int singleNumber(int[] nums){
        HashSet<Integer> hashSet=new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
                if(!hashSet.contains(nums[i])) {
                    hashSet.add(nums[i]);
                }else{
                    hashSet.remove(nums[i]);
                }
        }
        for (int i=0;i<nums.length;i++){
            if(hashSet.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }

    public static void main(String[] args) {

    }
}
